//
//  NetHelper.h
//  Test
//
//  Created by sdadmin on 2018/6/8.
//  Copyright © 2018年 sdadmin. All rights reserved.
//

#import <Foundation/Foundation.h>


/**
 请求成功回掉block

 @param response 成功值 --- 原则上是json字符串
 */
typedef void(^NetRequestSuccess)(__strong id response);



/**
 请求失败的block
 
 @param error 扩展信息
 */
typedef void(^NetRequestFail)(NSError * error);


@interface NetHelper : NSObject



/**
 无缓存Post请求

 @param urlStr 请求地址
 @param params 请求参数
 @param successBlock 成功回调
 @param failBlock 失败回掉
 @return 网络Task
 */
+(NSURLSessionTask *)requestNoCachePostWithUrlStr:(NSString *)urlStr
                                           params:(NSMutableDictionary *)params
                                     successBlock:(NetRequestSuccess)successBlock
                                        failBlock:(NetRequestFail)failBlock;

/**
 带缓存Post请求

 @param urlStr 请求地址
 @param params 请求参数
 @param cacheBlock 缓存回调
 @param successBlock 成功请求回调
 @param failBlock 失败请求回调
 @return 网络Task
 */
+(NSURLSessionTask *)requestCachePostWithUrlStr:(NSString *)urlStr
                                         params:(NSMutableDictionary *)params
                                     cacheBlock:(void(^)(id cacheData))cacheBlock
                                   successBlock:(NetRequestSuccess)successBlock
                                      failBlock:(NetRequestFail)failBlock;

/**
 AFpost请求

 @param urlStr 请求地址
 @param parameters 请求参数
 @param successblock 成功请求
 @param failblock 失败请求
 */
+ (void)requestWithUrlStr:(NSString *)urlStr
            andParameters:(NSDictionary *)parameters
           completedBlock:(NetRequestSuccess)successblock
             failuerBlock:(NetRequestFail)failblock;

@end
